<template>
    <el-container class="content">
        <el-aside width="200px">
            <el-menu :default-active="activeIndex" class="menu" router @open="handleOpen" :default-openeds="defaultOpeneds" unique-opened>
                <el-submenu index="1" title>
                    <template slot="title">
                        <span> {{ $t('member.home.memberCentre') }}</span>
                    </template>
                    <el-menu-item index="index"> {{ $t('member.home.welcomePage') }}</el-menu-item>
                    <el-menu-item index="info"> {{ $t('member.home.myAccount') }}</el-menu-item>
                    <!-- <el-menu-item index="my_coupon">优惠券</el-menu-item> -->
                    <el-menu-item index="collection"> {{ $t('member.home.myFocus') }}</el-menu-item>
                    <el-menu-item index="footprint"> {{ $t('member.home.myFootprint') }}</el-menu-item>
                    <el-menu-item index="delivery_address"> {{ $t('member.home.shippingAddress') }}</el-menu-item>
                    <el-menu-item index="security"> {{ $t('member.home.accountSecurity') }}</el-menu-item>
                </el-submenu>
                <el-submenu index="4" title>
                    <template slot="title">
                        <span> {{ $t('member.home.walletManagement') }}</span>
                    </template>
                  <el-menu-item :index="'blance'"> {{ $t('member.home.currencyAssets') }}</el-menu-item>
                  <el-menu-item :index="'points'"> {{ $t('member.home.pointsAccount') }}</el-menu-item>
                </el-submenu>
                <el-submenu index="2" title>
                    <template slot="title">
                        <span> {{ $t('member.home.tradingCenter') }}</span>
                    </template>
                    <el-menu-item index="order_list"> {{ $t('member.home.myOrder') }}</el-menu-item>
                    <el-menu-item index="activist"> {{ $t('member.home.reimburse') }}</el-menu-item>
                    <template v-if="is_verify == 1">
                        <el-menu-item index="verification"> {{ $t('member.home.writeOffStation') }}</el-menu-item>
                        <el-menu-item index="verification_list"> {{ $t('member.home.writeOffRecords') }}</el-menu-item>
                    </template>
                </el-submenu>
                <el-submenu index="3" title>
                    <template slot="title">
                        <span> {{ $t('member.home.accountCenter') }}</span>
                    </template>
                    <!-- <el-menu-item index="account">账户余额</el-menu-item>
                    <el-menu-item index="withdrawal">提现记录</el-menu-item> -->
                    <el-menu-item index="my_coupon"> {{ $t('member.home.myDiscountCoupon') }}</el-menu-item>
                    <!-- <el-menu-item index="my_point">我的积分</el-menu-item>
					<el-menu-item index="account_list">账户列表</el-menu-item> -->
                    <el-menu-item index="level"> {{ $t('member.home.joinMembership') }}</el-menu-item>
                    <el-menu-item index="proxy_index"> {{ $t('member.home.becomeAnAgent') }}</el-menu-item>
                </el-submenu>
            </el-menu>
        </el-aside>
        <el-main class="member">
            <transition name="slide"><router-view /></transition>
        </el-main>
    </el-container>
</template>
<script>
    import { checkisverifier } from "@/api/order/verification"
    export default {
        name: "home",
        components: {},
        data: () => {
            return {
                defaultOpeneds: ["1"],
                activeIndex: "index",
                is_verify: 1
            }
        },
        created() {
            this.activeIndex = this.$route.meta.parentRouter ||this.$route.path.replace("/member/", "")
            this.checkIsVerifier()
        },
        methods: {
            handleOpen(key, keyPath) {
                console.log(key)
                console.log(keyPath+'----')
                this.defaultOpeneds = keyPath
            },
            checkIsVerifier() {
                checkisverifier()
                    .then(res => {
                        if (res.data) {
                            this.is_verify = 1
                        }
                    })
                    .catch(err => {
                        this.is_verify = 0
                    })
            }
        },
        watch: {
            $route(curr) {
				this.activeIndex = curr.meta.parentRouter||this.$route.path.replace("/member/", "");
            }
        }
    }
</script>
<style lang="scss" scoped>
    .menu {
        min-height: 630px;
    }
    .content {
        display: flex !important;
        margin: 20px 0;
    }
    .member {
        margin-left: 15px;
    }
</style>
